#include "QtPrivateDeclar.h"

QtPrivateDeclar::QtPrivateDeclar(): d_ptr(new QtPrivateDeclarPrivate(this))
{
    
}
QtPrivateDeclar::QtPrivateDeclar(QJsonObject object) : d_ptr(new QtPrivateDeclarPrivate(this))
{
    QJsonObject obj = object;
    // obj.value("")
    if (obj.contains("category")){
        setCategory(obj.value("category").toString());
    }
    if (obj.contains("package")){
        setPackage(obj.value("package").toString());
    }
    if (obj.contains("path")){
        setPath(obj.value("path").toString());
    }
    if (obj.contains("file")){
        setFile(obj.value("file").toString());
    }
    if (obj.contains("version")){
        setVersion(obj.value("version").toString());
    }
    if (obj.contains("archs")){
        QJsonArray array = obj.value("archs").toArray();
        QStringList vals;
        for (int i = 0; i < array.count(); i++)
        {
            vals << array[i].toString();
        }
        
        setArchs(vals);
    }
    if (obj.contains("useflags")){
        QJsonArray array = obj.value("useflags").toArray();
        QStringList vals;
        for (int i = 0; i < array.count(); i++)
        {
            vals << array[i].toString();
        }
        
        setUseflags(vals);
    }
}

void QtPrivateDeclar::setCategory(QString category) {
    Q_D(QtPrivateDeclar);
    d->category = category;
}
QString QtPrivateDeclar::getCategory() {
    Q_D(QtPrivateDeclar);
    return d->category;
}

void QtPrivateDeclar::setPackage(QString package) {
    Q_D(QtPrivateDeclar);
    d->package = package;
}
QString QtPrivateDeclar::getPackage() {
    Q_D(QtPrivateDeclar);
    return d->package;
}

void QtPrivateDeclar::setPath(QString path) {
    Q_D(QtPrivateDeclar);
    d->path = path;
}
QString QtPrivateDeclar::getPath() {
    Q_D(QtPrivateDeclar);
    return d->path;
}

void QtPrivateDeclar::setFile(QString file) {
    Q_D(QtPrivateDeclar);
    d->file = file;
}
QString QtPrivateDeclar::getFile() {
    Q_D(QtPrivateDeclar);
    return d->file;
}

void QtPrivateDeclar::setVersion(QString version) {
    Q_D(QtPrivateDeclar);
    d->version = version;
}
QString QtPrivateDeclar::getVersion() {
    Q_D(QtPrivateDeclar);
    return d->version;
}

void QtPrivateDeclar::setArchs(QStringList archs) {
    Q_D(QtPrivateDeclar);
    d->archs = archs;
}
QStringList QtPrivateDeclar::getArchs() {
    Q_D(QtPrivateDeclar);
    return d->archs;
}

void QtPrivateDeclar::setUseflags(QStringList useflags) {
    Q_D(QtPrivateDeclar);
    d->useflags = useflags;
}
QStringList QtPrivateDeclar::getUseflags() {
    Q_D(QtPrivateDeclar);
    return d->useflags;
}
